﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Model.Sec
{
    /// <summary>
    /// 用户集合类
    /// </summary>
    public class UserCollection : IListSource
    {
        User[] _users;
        private int _Count;

        bool IListSource.ContainsListCollection
        {
            get { return false; }
        }

        System.Collections.IList IListSource.GetList()
        {
            BindingList<User> ble = new BindingList<User>();

            foreach (User user in _users)
            {
                ble.Add(user);
            }

            return ble;
        }

        /// <summary>
        /// 用户集合的构造函数
        /// </summary>
        public UserCollection(int Count)
        {
            this._Count = Count;
            _users = new User[this._Count];
        }
        /// <summary>
        /// 集合的长度
        /// </summary>
        public int Count
        {
            get { return _users.Length; }
        }
        /// <summary>
        /// 获取或设置索引为index的用户对象
        /// </summary>
        /// <param name="index">索引值</param>
        /// <returns>User对象</returns>
        public User this[int index]
        {
            get
            {
                return _users[index];
            }
            set
            {
                _users[index] = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public User[] Users
        {
            get { return this._users; }
        }
    }
}
